<template>
  <div class="policylibrary-news">
      <div class="hr10"></div>
      <Row>
        <Col span="24">
          <ul class="ulist">
            <!--
            <li v-for="(item,index) in corporateDataList" :key="index">
              <router-link :to="{ path:'detail/type/0/id/'+item.id}"><Icon type="ios-arrow-forward" />{{item.title}}</router-link>
              <span>{{item.publishDate | formatDate}}</span>
            </li>
            -->
            <article-list v-for="(item,index) in corporateDataList" :key="index"
              :id="item.id"
              :title="item.title"
              :publishDate="item.publishDate"
              @detail="openlink"
            >
            </article-list>
          </ul>
          <div style="float: right; margin: 10px">
            <Page 
            :total="total" 
            :current.sync="currentPage" 
            :page-size="pageSize"              
            @on-change="changeLibraryPage" 
            show-total
            show-elevator 
            show-sizer 
            @on-page-size-change="selectPage"
            :page-size-opts="[20,50,100]"
            ></Page>
          </div>
        </Col>
      </Row>
  </div>
</template>
<script>
import articleList from '@/views/components/list/articleList'
  export default {
    name: "PolicyLibraryNews",
    data(){
      return{
        policy_library:'PolicyLibraryNews',
        loading:false,
        total:0,
        pageSize:20,
        pageNum:1,
        currentPage:1,        
        currentIndustryName:"科技政策动态",//当前选择的分类
        corporateDataList:[]
      }
    },
    components:{
        articleList
    },
    methods:{
      getpolicyData(){//列表数据        
        let follow=999;
        let type=this.currentIndustryName=='全部'?"":this.currentIndustryName;
        let url=this.$url.baseUrl+'/consulting-library/api/policy/policy?follow='+follow+'&type='+type+'&pageSize='+this.pageSize+'&pageNum='+this.pageNum;
        this.$http.get(url).then(response =>{
            let result=response.data
            if (result.meta.success){
              //console.log(result.data)
              this.corporateDataList=result.data.list
              this.total=result.data.total
            }else {
              console.log("获取数据失败")
            }
        })
      },
      changeLibraryPage(index){
        this.pageNum=index;
        //console.log(index,'this.pageNum');
        this.getpolicyData(this.pageNum)
      },
      selectPage(index){
        this.pageSize=index;
        this.getpolicyData(this.pageNum)
        //console.log(index,'this.pageSize');
      },
      openlink(id){
        console.log(id,'id');
        this.$router.push({path:'detail/type/0/id/'+id});
      }
    },
    mounted() {
      this.getpolicyData()
      //console.log(this.$route.name,'$route.name');
      this.$store.state.hidemenu=true;//显示菜单项
      this.$store.state.submenuname='PolicyLibraryNews';//选中
    },
    watch:{

    },
    created(){

    },
    filters: {
      formatDate: function (value) {
        let date = new Date(value);
        let y = date.getFullYear();
        let MM = date.getMonth() + 1;
        MM = MM < 10 ? ('0' + MM) : MM;
        let d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        return y + '-' + MM + '-' + d;
      }
    }

  }
</script>

<style rel="stylesheet/less" lang="less" scoped>
.displayflex(){
  -webkit-display: flex;
  -moz-display: flex;
  display: flex;
}
.flexdiv(){
  -webkit-flex:1;
  -moz-flex:1;
  flex:1;
}
.hr10{
  height: 10px;
  line-height: 0;
  font-size: 0;
}
.hr20{
  height: 20px;
  line-height: 0;
  font-size: 0;
}
.policylibrary-news{
  width: 100%;
}
.ulist{
  li{
    
    margin:0;
    padding:0;
    list-style: none;
    line-height: 35px;
    height: 35px;
    overflow: hidden;
    font-size:14px;
    .displayflex();
    a{
      color: #222222;
      display: inline-block;
    }
    span{
      color:#999999;
      width: 100px;
      padding-right: 5px;
      text-align: right;
      margin-left: auto;
      display: inline-block;
    }
  }
}

</style>
